<?php
/**
 * @author xp
 */
$raw = file_get_contents('./encoded.txt');
$lines = explode("\n", $raw);

$filter = @$_GET['proto'] or null;
if (!is_string($filter)) {
    $filter = '';
}

$filtered = [];
foreach ($lines as $line) {
    $line = trim($line);
    if (empty($line)) continue;
    if ($line[0] == '#') continue;
    if (!empty($filter)) {
        if (strpos($line, $filter) !== 0) continue;
    }
    $filtered[] = $line;
}

echo base64_encode(implode("\n", $filtered));
